import { createApp } from "vue";
import "./style.css";
import App from "./App.vue";
import ElementPlus from "element-plus"; // Element 组件
import "element-plus/dist/index.css"; // Element 样式文件
import zhCn from "element-plus/dist/locale/zh-cn.mjs"; // 引入中文语言包
import { createPinia } from "pinia";
import { router } from "./common/router";
import axios from "axios";
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

/**
 * axios
 * pinia
 * vue-router
 * element-plus
 * md-editor-v3
 */

axios.defaults.baseURL = import.meta.env.VITE_API_BASE_URL; // 配置服务端

console.log("请求地址", import.meta.env.VITE_API_BASE_URL);

axios.defaults.headers.common["Authorization"] = `Bearer ${
  localStorage.getItem("token") || ""
}`;

const app = createApp(App);

app.provide("axios", axios); // 将 axios 注入到全局

const pinia = createPinia(); // 创建 pinia 实例

app.use(ElementPlus, { locale: zhCn }); // 设置语言包

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(pinia); // 使用 pinia

app.use(router);

app.mount("#app");
